﻿<navigation:Page xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  x:Class="VMWorkshop.Silverlight.Views.Demo" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:sl="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Demo Page">
    <StackPanel HorizontalAlignment="Left">
        <StackPanel HorizontalAlignment="Left" Margin="5" Visibility="{Binding ProductsGridVisibility}">
            <sl:DataGrid x:Name="productsGrid" 
                         AutoGenerateColumns="False"
                         GridLinesVisibility="Horizontal"
                         IsReadOnly="True"
                         ItemsSource="{Binding Products}"
                         SelectionMode="Single"
                         SelectionChanged="productsGrid_SelectionChanged"
                         Width="185">
                <sl:DataGrid.Columns>
                    <sl:DataGridTextColumn Header="Id" Binding="{Binding ProductId}" Visibility="Collapsed" />
                    <sl:DataGridTextColumn Header="Title" Binding="{Binding Title}" />
                    <sl:DataGridTextColumn Header="Description" Binding="{Binding Description}" />
                    <sl:DataGridTextColumn Header="Qty" Binding="{Binding QuantityOnHand}" />
                </sl:DataGrid.Columns>
            </sl:DataGrid>
        </StackPanel>
        <Grid x:Name="editGrid" Margin="5" Visibility="{Binding EditFormVisibility}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
                <ColumnDefinition Width="200" />
            </Grid.ColumnDefinitions>
            
            <TextBlock Text="Title" Grid.Column="0" Grid.Row="0" />
            <TextBlock Text="Description" Grid.Column="0" Grid.Row="1" />
            <TextBlock Text="Qty" Grid.Column="0" Grid.Row="2" />
            <TextBlock Text="Release Date" Grid.Column="0" Grid.Row="3" />
            <TextBlock Text="Price" Grid.Column="0" Grid.Row="4" />
            
            <TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Path=SelectedProduct.Title, Mode=TwoWay}" />
            <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Path=SelectedProduct.Description, Mode=TwoWay}" />
            <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Path=SelectedProduct.QuantityOnHand, Mode=TwoWay}" />
            <TextBox Grid.Column="1" Grid.Row="3" Text="{Binding Path=SelectedProduct.ReleaseDate, Mode=TwoWay}" />
            <TextBox Grid.Column="1" Grid.Row="4" Text="{Binding Path=SelectedProduct.Price, Mode=TwoWay}" />
            
            <Button x:Name="saveButton" Grid.Column="1" Grid.Row="5" Content="Save" Click="saveButton_Click" />
            
        </Grid>
        <StackPanel x:Name="updateMsg" Margin="5" Visibility="{Binding UpdateMessageVisibility}">
            <TextBlock Text="Your changes are saved." />
        </StackPanel>
    </StackPanel>
</navigation:Page>
